<?php
/**
 * Created by PhpStorm.
 * User: xpz
 * Date: 2022/11/1
 * Time: 13:26
 */

namespace app\admin\model;

use think\Model;
class Record extends Model
{
// 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    protected $updateTime = false;
    // 追加属性
    protected $append = [
    ];

    public function getType2Attr($value, $data)
    {
        if(!empty($data['type2'])){
            if($data['type'] == 0){//支出
                return getzhifunamebyid($data['type2']);
            } else {
//                echo $data['type2'];exit;
                return getshourunamebyid($data['type2']);
            }

        } else {
            return "";
        }
    }

    public function getIsOwnAttr($value, $data)
    {

        if($data['is_own'] == 1){//支出
            return '是';
        } else if($data['is_own'] == 2) {
            return '否';
        } else {
            return "";
        }


    }
    public function getTypeAttr($value, $data)
    {

            if($data['type'] == 0){//支出
                return '支出';
            } else if($data['type'] == 1) {
                return '收入';
            } else {
                return "";
            }


    }
}